
<?php
	$this->set_css($this->default_theme_path.'/flexigrid/css/flexigrid.css');
	$this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY);

	$this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery.noty.js');
	$this->set_js_lib($this->default_javascript_path.'/jquery_plugins/config/jquery.noty.config.js');
	$this->set_js_lib($this->default_javascript_path.'/common/lazyload-min.js');

	if (!$this->is_IE7()) {
		$this->set_js_lib($this->default_javascript_path.'/common/list.js');
	}

	$this->set_js($this->default_theme_path.'/flexigrid/js/cookies.js');
	$this->set_js($this->default_theme_path.'/flexigrid/js/flexigrid.js');
	$this->set_js($this->default_theme_path.'/flexigrid/js/jquery.form.js');
	$this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.numeric.min.js');
	$this->set_js($this->default_theme_path.'/flexigrid/js/jquery.printElement.min.js');

	/** Fancybox */
	$this->set_css($this->default_css_path.'/jquery_plugins/fancybox/jquery.fancybox.css');
	$this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.fancybox-1.3.4.js');
	$this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.easing-1.3.pack.js');

	/** Jquery UI */
	$this->load_js_jqueryui();

?>
<script type='text/javascript'>
	window.gcConf = typeof window.gcConf == 'undefined' ? {} : window.gcConf;
	window.gcConf = $.extend(window.gcConf,{
		unset_image_preview : <?php echo $this->unset_image_preview?'true':'false' ?>,
		unset_image_preview_anchor :<?php echo $this->unset_image_preview_anchor?'true':'false' ?>,
		subject_cls:'<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>',
		subject:'<?php echo $subject?>',
		state:<?php echo json_encode(ucfirst($this->getState()))?>
	}); 
	var base_url = '<?php echo base_url();?>';

	var subject = '<?php echo $subject?>';
	var ajax_list_info_url = '<?php echo $ajax_list_info_url; ?>';
	var unique_hash = '<?php echo $unique_hash; ?>';

	var message_alert_delete = "<?php echo $this->l('alert_delete'); ?>";
	function SetGridMainIcon(cls){
		$('i.app-icon').replaceWith($('<i></i>').addClass('app-icon').addClass(cls));
	}
</script>

<h3 class="modul-title" style="display:none;">
	<i class="app-icon"></i>&nbsp;<span class="grid-title"><?php echo $subject?></span>
</h3>
<div id='list-report-error' class='report-div error'></div>
<div id='list-report-success' class='report-div success report-list' <?php if($success_message !== null){?>style="display:block"<?php }?>><?php
if($success_message !== null){?>
	<p><?php echo $success_message; ?></p>
<?php }
?></div>
<div class="flexigrid ls grd-<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>" style='width: 100%;' data-unique-hash="<?php echo $unique_hash; ?>">
	<div id="hidden-operations" class="hidden-operations"></div>
	<!-- <div class="mDiv">
		<div class="ftitle">
			
		</div>
		<div title="<?php echo $this->l('minimize_maximize');?>" class="ptogtitle">
			<span></span>
		</div>
	</div> -->
	<div id='main-table-box' class="main-table-box ls">
<!-- 	<div class="fly-l"></div>
	<div class="fly-r"></div> -->
	<div class="list-title-pre">
		<h3><?php echo $this->l('list_title_pre'); ?> <?php echo $subject?></h3>
	</div>	
	<?php if(!$unset_add || !$unset_export || !$unset_print){?>
	<div class="tDiv ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-accordion-icons">
		<?php if(!$unset_add){?>
		<div class="tDiv2 ">
        <!-- 	<div class="btnseparator">
			</div> -->
			<button <?php echo !$this->config->dialog_forms?'onclick="document.location=\''.$add_url.'\'"':''?> href="<?php echo $add_url?>" id="add-button" class="add_button btn btn-large grd-btn-add <?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>">
				<i class="fa fa-plus"></i>&nbsp;<?php echo $this->l('list_add'); ?> <?php echo $subject?>
			</button>

			
		</div>
		<?php }?>
		<div class="tDiv3">
			<?php if(!$unset_export) { ?>
        	<a class="export-anchor" data-url="<?php echo $export_url; ?>" target="_blank">
				<div class="fbutton">
					<div>
						<span class="export"><?php echo $this->l('list_export');?></span>
					</div>
				</div>
            </a>
			<div class="btnseparator"></div>
			<?php } ?>
			<?php if(!$unset_print) { ?>
        	<a class="print-anchor" data-url="<?php echo $print_url; ?>">
				<div class="fbutton">
					<div>
						<span class="print"><?php echo $this->l('list_print');?></span>
					</div>
				</div>
            </a>
			<div class="btnseparator"></div>
			<?php }?>
		</div>
		<div class='clear'></div>
	</div>
	<?php }?>
	<div style="height:8px"></div>
	<div id='ajax_list' class="ajax_list">
		<?php echo $list_view?>
	</div>
	<div style="height:4px"></div>
	<?php echo form_open( $ajax_list_url, 'method="post" id="filtering_form" class="filtering_form" autocomplete = "off" data-ajax-list-info-url="'.$ajax_list_info_url.'"'); ?>
	<div class="sDiv quickSearchBox" id='quickSearchBox'>
		<div class="sDiv2">
			<?php echo $this->l('list_search');?>: <input type="text" class="qsbsearch_fieldox search_text" name="search_text" size="30" id='search_text'>
			<select name="search_field" id="search_field">
				<option value=""><?php echo $this->l('list_search_all');?></option>
				<?php foreach($columns as $column){?>
				<option value="<?php echo $column->field_name?>"><?php echo $column->display_as?>&nbsp;&nbsp;</option>
				<?php }?>
			</select>
            <input type="button" value="<?php echo $this->l('list_search');?>" class="crud_search" id='crud_search'>
		</div>
        <div class='search-div-clear-button'>
        	<input type="button" value="<?php echo $this->l('list_clear_filtering');?>" id='search_clear' class="search_clear">
        </div>
	</div>
	<div style="height:4px"></div>
	<div class="pDiv ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-accordion-icons">
		<div class="pDiv2">
			<div class="pGroup">
				<div class="pReload pButton ajax_refresh_and_loading" id='ajax_refresh_and_loading'>
					<span class="ui-icon ui-icon-refresh"></span>
				</div>
			</div>
			<div class="pGroup">
				<div class="pSearch pButton quickSearchButton" id='quickSearchButton' title="<?php echo $this->l('list_search');?>">
					<span class="ui-icon ui-icon-search"></span>
				</div>
			</div>
			<div class="btnseparator">
			</div>
			<div class="pGroup">
				<select name="per_page" id='per_page' class="per_page">
					<?php foreach($paging_options as $option){?>
						<option value="<?php echo $option; ?>" <?php if($option == $default_per_page){?>selected="selected"<?php }?>><?php echo $option; ?>&nbsp;&nbsp;</option>
					<?php }?>
				</select>
				<input type='hidden' name='order_by[0]' id='hidden-sorting' class='hidden-sorting' value='<?php if(!empty($order_by[0])){?><?php echo $order_by[0]?><?php }?>' />
				<input type='hidden' name='order_by[1]' id='hidden-ordering' class='hidden-ordering'  value='<?php if(!empty($order_by[1])){?><?php echo $order_by[1]?><?php }?>'/>
			</div>
			<div class="btnseparator">
			</div>
			<div class="pGroup">
				<div class="pFirst pButton first-button">
					<span class="ui-icon ui-icon-seek-first"></span>
				</div>
				<div class="pPrev pButton prev-button">
					<span class="ui-icon ui-icon-seek-prev"></span>
				</div>
			</div>
			<div class="btnseparator">
			</div>
			<div class="pGroup">
				<span class="pcontrol"><?php echo $this->l('list_page'); ?> <input name='page' type="text" value="1" size="4" id='crud_page' class="crud_page">
				<?php echo $this->l('list_paging_of'); ?>
				<span id='last-page-number' class="last-page-number"><?php echo ceil($total_results / $default_per_page)?></span></span>
			</div>
			<div class="btnseparator">
			</div>
			<div class="pGroup">
				<div class="pNext pButton next-button" >
					<span class="ui-icon ui-icon-seek-next"></span>
				</div>
				<div class="pLast pButton last-button">
					<span class="ui-icon ui-icon-seek-end"></span>
				</div>
			</div>
			<!-- <div class="btnseparator">
			</div>
			 -->
			<!-- <div class="btnseparator">
			</div> -->
			<div class="pGroup" style="float:right">
				<span class="pPageStat">
					<?php $paging_starts_from = "<span id='page-starts-from' class='page-starts-from'>1</span>"; ?>
					<?php $paging_ends_to = "<span id='page-ends-to' class='page-ends-to'>". ($total_results < $default_per_page ? $total_results : $default_per_page) ."</span>"; ?>
					<?php $paging_total_results = "<span id='total_items' class='total_items'>$total_results</span>"?>
					<?php echo str_replace( array('{start}','{end}','{results}'),
											array($paging_starts_from, $paging_ends_to, $paging_total_results),
											$this->l('list_displaying')
										   ); ?>
				</span>
			</div>
		</div>
		<div style="clear: both;">
		</div>
	</div>
	<?php echo form_close(); ?>

	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	// window.parent.jQuery('ul.menu-bar > li > a').css({'color':'#d3d3d3','font-weight':'normal'});
	// window.parent.jQuery('ul.user-menu > li > a').css({'color':'#d3d3d3','font-weight':'normal'});
	$('.list-title-pre > h3').hide()
	setTimeout(function(){
		// var hClone = $('h3.modul-title').clone(true).css('display','block');
		// $('h3.modul-title').remove();
		// var moduleInfo = window.parent.jQuery('div.modul-info');
		

		// var activeMenu = window.parent.jQuery('ul.menu-bar > li > a.<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>');
		// if( !activeMenu.length )
		// 	activeMenu = window.parent.jQuery('ul.user-menu > li > a.<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>');
		// activeMenu.css({'color':'orange','font-weight':'bold'});
		// var tt = activeMenu.find('>i').attr('mt');
		// moduleInfo.empty().append(hClone.html(tt));

		//var caption = ;
		var txt = parent.jQuery('ul.menu-bar > li > a.active').html();
		$('.list-title-pre > h3').html(txt).fadeIn()
	},200)
	
});
</script>
